<?php
/**
 * 红包游戏安全校验中间件
 */

namespace App\Http\Middleware;

use Closure;
use App\Exceptions\BasicException;

class RedEnvelopeMiddleware
{
    public function handle($request, Closure $next)
    {
        $inputGameToken = $request->input('game_token');

        $curGameToken = env("GAME_TOKEN");

        if (empty($curGameToken) || $inputGameToken != $curGameToken) {
            return response()->json('ok', -1, [
                'status' => -1,
                'info'   => '令牌不合法！',
                'data'   => '',
            ]);
        }

        return $next($request);
    }
}
